{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8a27d39b",
   "metadata": {},
   "source": [
    "# 学习时间-2022-09-20\n",
    "# 学习笔记-python\n",
    "# 记录者：张钰华"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "59679193",
   "metadata": {},
   "source": [
    "# 回顾知识--字符串\n",
    "* 1.type(数据类型)--辨别(引号)\n",
    "* 2.in()检查成员对象\n",
    "* 3.拼接“+”\n",
    "* 4.方法：只要生成字符串，就有所对应的缩影值(不存在与存在的数值);去一定范围的值(切片)；可以用枚举(enumerate)列出只是存在的值以及缩影值(由0开始)；range（0：5）或者(0:5)的数值范围是左开右闭的范围\n",
    "* 5.count(); split()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "667ffeb5",
   "metadata": {},
   "source": [
    "# 本周内容\n",
    "* 有序数据结构及列表\n",
    "* 用户输入\n",
    "* 关于格式化文本信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "18dd30ac",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 可在一个空间里存放数据（字符串）\n",
    "#处理数据的方法有些问题(遇到数值比较复杂时)\n",
    "# 引入：列表(存放) list[要么一起放数值，要么一起放字符串]，它可以处理数值和字符串，但必须处理的是同一种类的值。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "574b4c2d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4] <class 'list'>\n"
     ]
    }
   ],
   "source": [
    "b = [1, 2, 3, 4]\n",
    "print(b,type(b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "f5c49a0a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['never', 'jack', 'mary'] <class 'list'>\n"
     ]
    }
   ],
   "source": [
    "letter = [\"never\" ,\"jack\",\"mary\"]\n",
    "print(letter,type(letter))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "56a74f5c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(letter)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "6dcef63d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "letter never\n",
      "letter jack\n",
      "letter mary\n"
     ]
    }
   ],
   "source": [
    "for i in letter:\n",
    "    print(\"letter\",i)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "ba187b1d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# in可以检查成员对象是否存在\n",
    "\"mary\" in letter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "f60e9660",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"tobby\" in letter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "dacb2f07",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 有序数据的运算法则(运算法则的操作不会改变列表本身的形态)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "fb51f68c",
   "metadata": {},
   "outputs": [],
   "source": [
    "letter_answer = [\"pop\",\"lisa\",\"twice\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "fbe77f38",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['never', 'jack', 'mary', 'pop', 'lisa', 'twice']"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letter + letter_answer "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "c81800ea",
   "metadata": {},
   "outputs": [],
   "source": [
    "#一个list可以存在重复项\n",
    "answer = [19,20,21,20,21,19,20]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "b2149ae3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[19, 20, 21, 20, 21, 19, 20]\n"
     ]
    }
   ],
   "source": [
    "print(answer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "c5906fc5",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 列表方法（列表.Tab)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "e2685377",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<function list.reverse()>"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letter.append\n",
    "letter.clear\n",
    "letter.copy\n",
    "letter.extend\n",
    "letter.insert\n",
    "letter.reverse\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "2cd2f044",
   "metadata": {},
   "outputs": [],
   "source": [
    "#追加; (在文章后面)附加，增补;（增加元素到末尾）append\n",
    "letter.append(\"blackpink\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "359f2d14",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['never', 'jack', 'mary', 'blackpink']"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "b39c1bbc",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function insert:\n",
      "\n",
      "insert(index, object, /) method of builtins.list instance\n",
      "    Insert object before index.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(letter.insert)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "b664fce4",
   "metadata": {},
   "outputs": [],
   "source": [
    "# insert(index, object, /)  Insert object before index.\n",
    "letter.insert(2,\"ive\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "17a429a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['never', 'jack', 'ive', 'mary', 'blackpink']"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "b655cde3",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function remove:\n",
      "\n",
      "remove(value, /) method of builtins.list instance\n",
      "    Remove first occurrence of value.\n",
      "    \n",
      "    Raises ValueError if the value is not present.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(letter.remove)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "8da36818",
   "metadata": {},
   "outputs": [],
   "source": [
    "# remove(value, /) Remove first occurrence of value.\n",
    "letter.remove(\"ive\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "87b008b5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['never', 'jack', 'mary', 'blackpink']"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "ac2a98c8",
   "metadata": {},
   "outputs": [],
   "source": [
    "# remove 不能清除已经不在的数值，如果remove不在的数据，则会出现报错。\n",
    "# 因此remove语法与in语法一起使用。先检查成员对象是否存在，之后再进行remove(清除)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "1997fc01",
   "metadata": {},
   "outputs": [],
   "source": [
    "if \"ive\" in letter:\n",
    "    letter.remove(\"ive\")\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "68306374",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['never', 'jack', 'mary', 'blackpink']"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "ac410419",
   "metadata": {},
   "outputs": [],
   "source": [
    "# sort 排序 ；倒序\n",
    "letter.sort()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "8990395a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['blackpink', 'jack', 'mary', 'never']"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "4a79fe46",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function sort:\n",
      "\n",
      "sort(*, key=None, reverse=False) method of builtins.list instance\n",
      "    Sort the list in ascending order and return None.\n",
      "    \n",
      "    The sort is in-place (i.e. the list itself is modified) and stable (i.e. the\n",
      "    order of two equal elements is maintained).\n",
      "    \n",
      "    If a key function is given, apply it once to each list item and sort them,\n",
      "    ascending or descending, according to their function values.\n",
      "    \n",
      "    The reverse flag can be set to sort in descending order.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(letter.sort)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "561c392d",
   "metadata": {},
   "outputs": [],
   "source": [
    "#clear(所有内容全部清除)\n",
    "letter.clear()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "08638838",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "c6161e71",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function clear:\n",
      "\n",
      "clear() method of builtins.list instance\n",
      "    Remove all items from list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(letter.clear)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "70730071",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function pop:\n",
      "\n",
      "pop(index=-1, /) method of builtins.list instance\n",
      "    Remove and return item at index (default last).\n",
      "    \n",
      "    Raises IndexError if list is empty or index is out of range.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(letter.pop)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "41de56ba",
   "metadata": {},
   "outputs": [],
   "source": [
    "# pop默认删除最后一位的值，如果超出了列表的值或是空值，则会报错哟！（列表是有一定的范围取值）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "2e46de20",
   "metadata": {},
   "outputs": [],
   "source": [
    "answer = [19,20,21,20,21,19,20]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "89c9c033",
   "metadata": {},
   "outputs": [],
   "source": [
    "if 19 in answer:\n",
    "    answer.remove(19)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "fb302774",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[20, 21, 20, 21, 20]"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "answer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "f7abca7d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "answer.count(20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "95082d27",
   "metadata": {},
   "outputs": [],
   "source": [
    "删除的数量 = answer.count(20)\n",
    "for i in range(删除的数量):\n",
    "    if 20 in answer:\n",
    "        answer.remove(20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "a5e370c3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[21, 21]"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "answer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "eb1de47d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "21\n",
      "21\n"
     ]
    }
   ],
   "source": [
    "for i in answer:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "9b3a7fbe",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 21\n"
     ]
    }
   ],
   "source": [
    "for i,v in enumerate(answer):\n",
    "    if v == 21:\n",
    "        print(i,v)\n",
    "        answer.pop(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "a0d40543",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[21]"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "answer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "4b513ff2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panic!\n",
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n",
      "['o', 'n', ' ', 't', 'a', 'p']\n",
      "on tap\n"
     ]
    }
   ],
   "source": [
    "# 课本练习一\n",
    "phrase = \"Don't panic!\"\n",
    "plist = list(phrase)\n",
    "print(phrase)\n",
    "print(plist)\n",
    "for i in range(4):\n",
    "    plist.pop()\n",
    "plist.pop(0)\n",
    "plist.remove(\"'\")\n",
    "plist.extend([plist.pop(),plist.pop()])\n",
    "plist.insert(2,plist.pop(3))\n",
    "new_phrase = ''.join(plist)\n",
    "print(plist)\n",
    "print(new_phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "af78c12e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panic!\n",
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n",
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n",
      "on tap\n"
     ]
    }
   ],
   "source": [
    "# 课本练习二\n",
    "phrase = \"Don't panic!\"\n",
    "plist = list(phrase)\n",
    "print(phrase)\n",
    "print(plist)\n",
    "new_phrase = ''.join(plist[1:3])\n",
    "new_phrase = new_phrase + ''.join([plist[5],plist[4],plist[7],plist[6]])\n",
    "print(plist)\n",
    "print(new_phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "986eed7e",
   "metadata": {},
   "outputs": [],
   "source": [
    "name_list = \"twice\",\"blackpink\",\"itzy\",\"dreamcatcher\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "203d9c22",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('twice', 'blackpink', 'itzy', 'dreamcatcher')"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "aafbc963",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['ommgirl', 'twice', 'blackpink', 'itzy', 'dreamcatcher'] <class 'list'>\n"
     ]
    }
   ],
   "source": [
    "letter = [\"ommgirl\",\"twice\",\"blackpink\",\"itzy\",\"dreamcatcher\"]\n",
    "print(letter,type(letter))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "92feae05",
   "metadata": {},
   "outputs": [],
   "source": [
    "#剩下的reserve，extend，clear，copy，sort用法\n",
    "# 1.reserve(颠倒，替换位置；一般默认为从尾到头的交换位置)\n",
    "letter.reverse()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "6345330e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['dreamcatcher', 'itzy', 'blackpink', 'twice', 'ommgirl']"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "fd9ddb45",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function reverse:\n",
      "\n",
      "reverse() method of builtins.list instance\n",
      "    Reverse *IN PLACE*.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(letter.reverse)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "90229b2c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 2.extend(延长，扩大)\n",
    "# iterable, /(可迭代的重复对象，既要新添一组数据)，与‘+’用法相似\n",
    "letter_ask = [\"ive\",\"mamamoo\",\"keper1\",\"jessi\",\"teyone\"]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "fccbe91b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function extend:\n",
      "\n",
      "extend(iterable, /) method of builtins.list instance\n",
      "    Extend list by appending elements from the iterable.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(letter.extend)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "0d82606b",
   "metadata": {},
   "outputs": [],
   "source": [
    "letter.extend(letter_ask)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "71fc7f1e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['dreamcatcher',\n",
       " 'itzy',\n",
       " 'blackpink',\n",
       " 'twice',\n",
       " 'ommgirl',\n",
       " 'ive',\n",
       " 'mamamoo',\n",
       " 'keper1',\n",
       " 'jessi',\n",
       " 'teyone']"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "8f3564a4",
   "metadata": {},
   "outputs": [],
   "source": [
    "sth_new = [\"he\",\"be\",\"oe\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "fe8d1754",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['he', 'be', 'oe']"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sth_new"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "6141b140",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 3.sort(对给定区间所有元素进行排序,即将元素从小到大升序排序)\n",
    "sth_new.sort()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "673eb729",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['be', 'he', 'oe']"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sth_new"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "9d910488",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function sort:\n",
      "\n",
      "sort(*, key=None, reverse=False) method of builtins.list instance\n",
      "    Sort the list in ascending order and return None.\n",
      "    \n",
      "    The sort is in-place (i.e. the list itself is modified) and stable (i.e. the\n",
      "    order of two equal elements is maintained).\n",
      "    \n",
      "    If a key function is given, apply it once to each list item and sort them,\n",
      "    ascending or descending, according to their function values.\n",
      "    \n",
      "    The reverse flag can be set to sort in descending order.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(sth_new.sort)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "c42b9e14",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['be', 'he', 'oe']"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 4.copy\n",
    "# 复制文本\n",
    "sth_new.copy()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "00585630",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['be', 'he', 'oe']"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sth_new"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "bf452ef5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function copy:\n",
      "\n",
      "copy() method of builtins.list instance\n",
      "    Return a shallow copy of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(sth_new.copy)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "aa367508",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 5.clear(文本数据全部清除）\n",
    "sth_new.clear()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "3847b186",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sth_new"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b1779d9b",
   "metadata": {},
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "66110146",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
